<?php
class WebloginAction extends Action {
	function login(){
		header("Content-Type:text/html;charset=utf-8");
		$userName =trim( $_REQUEST['userName']);
		$password = md5(trim($_REQUEST['password']));
		
		if(empty($userName) || empty($password)){
			return false;

		}

		$Member = M('member');
		$member = $Member->getByTelephone($userName);
		if(!$member){
			echo "-1";
			return false;  // error userName;
		}
		if($member['password'] !=$password){
			echo "-2";
			return false; // error password
		}

		$uid = $member['id'];
		$Card = M('Card');
		$card  = $Card->where('memberId='.$uid)->find();

		$data['member'] = $member;
		$data['card']        = $card;
		echo json_encode($data);

	}

	function index(){
		$this->login();
	}
}